﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KiDS_Bootstrap
{
	/// <summary>
	/// Klasa koja predstavlja BOOTSTRAP_UNREGISTER_SERVENT_COMMAND
	/// </summary>
	public class BootstrapUnregisterServentCommand : Command
	{
		private string p;

		public unsafe BootstrapUnregisterServentCommand(SOCKET socket, string p)
		 : base(socket){
			this.p = p;
		}
		public override void DoCommmand()
		{
			string[] msg = p.Split(',');
			int index = Pinger.Instance.IndexOf(p);
			if (index != -1)
			{
				Pinger.Instance.Remove(index);
				Native.SendMessage(CMD.CMD_REPLY_OK + "", _socket);
			}
			else
			{
				Native.SendMessage(CMD.CMD_REPLY_FAIL + " " + CMD.ERROR_GEOLEVEL_NOT_FOUND, _socket);
			}
			Native.SendMessage("", _socket);

			Native.closesocket(_socket);
		}
	}
}
